package com.example.springpethospital.controller;

import com.example.springpethospital.common.reponse.BaseResponse;
import com.example.springpethospital.common.reponse.EntityResponse;
import com.example.springpethospital.common.reponse.ListPagingResponse;
import com.example.springpethospital.common.service.BaseController;
import com.example.springpethospital.entity.examination.dto.ExaminationDTO;
import com.example.springpethospital.entity.examination.dto.ExaminationPaperDTO;
import com.example.springpethospital.entity.examination.param.ExaminationPaperQueryParam;
import com.example.springpethospital.entity.examination.param.ExaminationQueryParam;
import com.example.springpethospital.entity.examination.param.ExaminationQuestionQueryParam;
import com.example.springpethospital.entity.examination.po.ExaminationPO;
import com.example.springpethospital.entity.examination.po.ExaminationPaperPO;
import com.example.springpethospital.entity.examination.po.ExaminationQuestionPO;
import com.example.springpethospital.service.ExaminationService;
import java.util.List;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 考试相关
 */
@RestController
@RequestMapping("/api/examination")
@CrossOrigin(originPatterns = "*", allowCredentials = "true", allowedHeaders = "*")
public class ExaminationController extends BaseController {

    @Autowired
    private ExaminationService examinationService;

    @PostMapping("/question/create")
    EntityResponse<Integer> questionCreate(@RequestBody ExaminationQuestionPO examinationQuestion) {
        return examinationService.questionCreate(examinationQuestion);
    }

    @PostMapping("/question/update")
    BaseResponse questionUpdate(@RequestBody ExaminationQuestionPO examinationQuestion) {
        return examinationService.questionUpdate(examinationQuestion);
    }

    @PostMapping("/question/page")
    ListPagingResponse<ExaminationQuestionPO> questionPage(@RequestBody @Valid ExaminationQuestionQueryParam queryParam) {
        return examinationService.questionPage(queryParam);
    }

    @PostMapping("/question/batchDelete")
    BaseResponse batchDeleteQuestion(@RequestBody @Valid List<@NotNull Integer> questionIds) {
        return examinationService.batchDeleteQuestion(questionIds);
    }

    @PostMapping("/paper/create")
    EntityResponse<Integer> paperCreate(@RequestBody @Valid ExaminationPaperPO param) {
        return examinationService.paperCreate(param);
    }

    @PostMapping("/paper/update")
    BaseResponse paperUpdate(@RequestBody @Valid ExaminationPaperPO param) {
        return examinationService.paperUpdate(param);
    }

    @PostMapping("/paper/page")
    ListPagingResponse<ExaminationPaperDTO> paperPage(@RequestBody @Valid ExaminationPaperQueryParam param) {
        return examinationService.paperPage(param);
    }

    @PostMapping("/paper/batchDelete")
    BaseResponse batchDeletePaper(@RequestBody @Valid List<@NotNull Integer> paperIds) {
        return examinationService.batchDeletePaper(paperIds);
    }

    @PostMapping("/exam/create")
    EntityResponse<Integer> examCreate(@RequestBody ExaminationPO param) {
        return examinationService.examCreate(param);
    }

    @PostMapping("/exam/update")
    BaseResponse examUpdate(@RequestBody ExaminationPO param) {
        return examinationService.examUpdate(param);
    }

    @PostMapping("/exam/page")
    ListPagingResponse<ExaminationDTO> examPage(@RequestBody @Valid ExaminationQueryParam param) {
        return examinationService.examPage(param);
    }

    @PostMapping("/exam/batchDelete")
    BaseResponse batchDeleteExam(@RequestBody @Valid List<@NotNull Integer> examIds) {
        return examinationService.batchDeleteExam(examIds);
    }


}
